package xianchengpool;

import java.util.Random;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @功能
 * @创建时间 2019/12/26
 * 定时器线程池
 */
public class T10_SchedulePool {
    public static void main(String[] args) {
        ScheduledExecutorService service = Executors.newScheduledThreadPool(2);
        service.scheduleAtFixedRate(()->{ // 以固定频率执行任务
            try {
                TimeUnit.MILLISECONDS.sleep(0);
                System.err.println(1111);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
        },5000,5000,TimeUnit.MILLISECONDS);
    }
}
